//
//  ChargeCell.m
//  LoveFreshBeen
//
//  Created by 魏根 on 2016/10/20.
//  Copyright © 2016年 魏根. All rights reserved.
//

#import "ChargeCell.h"
#import "MyCouponModel.h"

@interface ChargeCell ()
@property (weak, nonatomic) IBOutlet UIImageView *backImageView;
@property (weak, nonatomic) IBOutlet UIImageView *cicleImageView;
@property (weak, nonatomic) IBOutlet UILabel *valueLabel;
@property (weak, nonatomic) IBOutlet UILabel *isUsedLabel;
@property (weak, nonatomic) IBOutlet UIView *lineView;
@property (weak, nonatomic) IBOutlet UILabel *descriptionLabel;
@property (weak, nonatomic) IBOutlet UILabel *timeLabel;
@property (weak, nonatomic) IBOutlet UILabel *nameLabel;


@end

@implementation ChargeCell

- (void)setModel:(MyCouponModel *)model{
    
    _model = model;
    
    if (model.is_userd.integerValue) {
        self.backImageView.image = [UIImage imageNamed:@"v2_coupon_gray"];
        
        self.isUsedLabel.text = @"已使用";
        self.isUsedLabel.font = [UIFont systemFontOfSize:12];
        
        self.cicleImageView.backgroundColor = [UIColor grayColor];
        
    }else{
        self.backImageView.image = [UIImage imageNamed:@"v2_coupon_yellow"];
        
        self.isUsedLabel.hidden = YES;
        
        self.cicleImageView.backgroundColor = [UIColor colorWithRed:252/255.0 green:212/255.0 blue:52/255.0 alpha:1.0];
    }
    
    self.cicleImageView.layer.cornerRadius = 42;
    self.cicleImageView.clipsToBounds = YES;
    
    self.nameLabel.text = model.name;
    self.nameLabel.font = [UIFont systemFontOfSize:12];
    
    self.descriptionLabel.text = model.myDescription;
    self.descriptionLabel.font = [UIFont systemFontOfSize:10];
    self.descriptionLabel.preferredMaxLayoutWidth = 230;
    
    self.valueLabel.text = [NSString stringWithFormat:@"$%.1f",model.value.floatValue];
    if(((int)(model.value.floatValue * 10)) % 10 == 0){
        
        self.valueLabel.text = [NSString stringWithFormat:@"$%.0f",model.value.floatValue];
    }
    self.valueLabel.textColor = [UIColor whiteColor];
    self.valueLabel.font = [UIFont fontWithName:@"Helvetica-Bold" size:15];
    self.valueLabel.textAlignment = NSTextAlignmentCenter;
    
    
    self.timeLabel.text = [NSString stringWithFormat:@"有效期 %@ 至 %@",model.start_time,model.end_time];
    self.timeLabel.font = [UIFont systemFontOfSize:12];
}

- (void)awakeFromNib {
    [super awakeFromNib];
    
    [self setUpUI];
}

- (void)setUpUI{
    
    
}

@end
